from xiamicollection import *
import unittest

class TestXCCrawler(unittest.TestCase):
    def __init__(self):
        self.infodic = getxiamicollectioninfo(8612850)

    def testbasicinfo(self):
        self.assertEqual(self.infodic['uid'],1809279)
        self.assertEqual(self.infodic['date'],"2011-11-29")

    def testtags(self):
        count = self.infodic['tags'].count("留恋")
        self.assertEqual(count,1)

    def testcount(self):
        self.assertEqual(self.infodic['count'][0]['songcount'],50)
        self.assertEqual(self.infodic['count'][0]['playcount'],757)
        self.assertEqual(self.infodic['count'][0]['viewcount'],546)
        self.assertEqual(self.infodic['count'][0]['recommendcount'],14)
        self.assertEqual(self.infodic['count'][0]['storecount'],15)

    def testsongs(self):
        songs = self.infodic['songs']
        self.assertEqual(songs[0]['songid'],2099316))
        self.assertEqual(songs[0]['artistid'],23788))
        self.assertEqual(songs[0]['desp'].count("等闲"),1)

#class TestG(

if __name__ == "__main__":
    unittest.main()
